<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24" >
            <a-form-item label="计划开始时间 起">
              <a-date-picker style="width:100%;" @change="(date, dateString) => this.queryParam.startTime = dateString"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="至">
              <a-date-picker style="width:100%;" @change="(date, dateString) => this.queryParam.endTime = dateString"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button  type="primary" icon="search" @click="searchQuery">查询</a-button>
              <a-button type="primary" icon="reload" style="margin-left: 8px" @click="searchReset">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <a-tabs default-active-key="all" @change="callback">
      <a-tab-pane key="all" tab="全部"></a-tab-pane>
      <a-tab-pane :key="0" tab="客户关系维护"></a-tab-pane>
      <a-tab-pane :key="1" tab="台账"></a-tab-pane>
      <a-tab-pane :key="2" tab="客户节点"></a-tab-pane>
    </a-tabs>
    <!-- table区域-begin -->
    <div>
      <a-table
        size="middle"
        bordered
        row-key="id"
        :columns="columns"
        :data-source="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">办理</a>
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'Backlog',
  mixins: [JeecgListMixin],
  data() {
    return {
      dateFormat: 'YYYY/MM/DD',
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '待办项',
          align: 'center',
          dataIndex: 'record'
        },
        {
          title: '担当人',
          align: 'center',
          dataIndex: 'asPeople'
        },
        {
          title: '计划完成时间',
          align: 'center',
          dataIndex: 'planEndTime'
        },
        {
          title: '待办类型',
          align: 'center',
          dataIndex: 'type',
          customRender: function(t, r, index) {
            if(t === 0){
              return '客户关系维护'
            }else if(t === 1){
              return '台账'
            }else if(t === 2){
              return '客户节点'
            }
          }
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/backlog/list'
      }
    }
  },
  methods: {
    callback(activeKey){
      if(activeKey === 'all'){
        this.queryParam.type = ''
      }else{
        this.queryParam.type = activeKey
      }
      this.loadData()
    },
    handleEdit(record){
      record.url && this.$router.push({path:record.url})
    }
  }
}
</script>
